home *** CD-ROM | disk | FTP | other *** search
/ Isometric Game Programming with DirectX 7.0 / Isometric Game Programming.iso / directx / dxf / samples / multimedia / direct3d / enhancedmesh / enhancedmesh.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-04  |  18.4 KB  |  545 lines

  1. //-----------------------------------------------------------------------------
  2. // File: EnhancedMesh.cpp
  3. //
  4. // Desc: Sample showing enhanced meshes in D3D
  5. //
  6. // Copyright (c) 1999-2000 Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #define STRICT
  9. #include <windows.h>
  10. #include <commdlg.h>
  11. #include <tchar.h>
  12. #include <stdio.h>
  13. #include <d3dx8.h>
  14. #include "D3DApp.h"
  15. #include "D3DFont.h"
  16. #include "D3DUtil.h"
  17. #include "DXUtil.h"
  18. #include "resource.h"
  19.  
  20.  
  21.  
  22. //-----------------------------------------------------------------------------
  23. // Name: class CMyD3DApplication
  24. // Desc: Application class. The base class (CD3DApplication) provides the 
  25. //       generic functionality needed in all Direct3D samples. CMyD3DApplication 
  26. //       adds functionality specific to this sample program.
  27. //-----------------------------------------------------------------------------
  28. class CMyD3DApplication : public CD3DApplication
  29. {
  30.     TCHAR               m_strMeshFilename[512];
  31.     TCHAR               m_strInitialDir[512];
  32.  
  33.     LPD3DXMESH          m_pMeshSysMem;      // system memory version of mesh, lives through resize's
  34.     LPD3DXMESH          m_pMeshEnhanced;    // vid mem version of mesh that is enhanced
  35.     UINT                m_dwNumSegs;        // number of segments per edge (tesselation level)
  36.     D3DXMATERIAL*       m_pMaterials;       // pointer to material info in m_pbufMaterials
  37.     LPDIRECT3DTEXTURE8* m_ppTextures;       // array of textures, entries are NULL if no texture specified
  38.     DWORD               m_dwNumMaterials;   // number of materials
  39.  
  40.     CD3DFont*           m_pFont;
  41.     CD3DArcBall         m_ArcBall;          // mouse rotation utility
  42.     D3DXVECTOR3         m_vObjectCenter;    // Center of bounding sphere of object
  43.     FLOAT               m_fObjectRadius;    // Radius of bounding sphere of object
  44.  
  45.     LPD3DXBUFFER        m_pbufMaterials;    // contains both the materials data and the filename strings
  46.     LPD3DXBUFFER        m_pbufAdjacency;    // Contains the adjacency info loaded with the mesh
  47.  
  48.     BOOL                m_bUseHWNPatches; 
  49.  
  50.     HRESULT GenerateEnhancedMesh(UINT cNewNumSegs);
  51.  
  52. protected:
  53.     HRESULT OneTimeSceneInit();
  54.     HRESULT InitDeviceObjects();
  55.     HRESULT RestoreDeviceObjects();
  56.     HRESULT InvalidateDeviceObjects();
  57.     HRESULT DeleteDeviceObjects();
  58.     HRESULT Render();
  59.     HRESULT FrameMove();
  60.     HRESULT FinalCleanup();
  61.     LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  62.  
  63. public:
  64.     CMyD3DApplication();
  65. };
  66.  
  67.  
  68.  
  69.  
  70. //-----------------------------------------------------------------------------
  71. // Name: WinMain()
  72. // Desc: Entry point to the program. Initializes everything, and goes into a
  73. //       message-processing loop. Idle time is used to render the scene.
  74. //-----------------------------------------------------------------------------
  75. INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
  76. {
  77.     CMyD3DApplication d3dApp;
  78.  
  79.     if( FAILED( d3dApp.Create( hInst ) ) )
  80.         return 0;
  81.     return d3dApp.Run();
  82. }
  83.  
  84.  
  85.  
  86.  
  87. //-----------------------------------------------------------------------------
  88. // Name: CMyD3DApplication()
  89. // Desc: Application constructor. Sets attributes for the app.
  90. //-----------------------------------------------------------------------------
  91. CMyD3DApplication::CMyD3DApplication()
  92. {
  93.     m_strWindowTitle    = _T("Enhanced Mesh - N-Patches");
  94.     m_bUseDepthBuffer   = TRUE;
  95.     m_bShowCursorWhenFullscreen = TRUE;
  96.  
  97.     m_pMeshSysMem     = NULL;
  98.     m_pMeshEnhanced   = NULL;
  99.     m_pMaterials      = NULL;
  100.     m_ppTextures      = NULL;
  101.     m_dwNumMaterials  = NULL;
  102.     m_pbufMaterials   = NULL;
  103.     m_pbufAdjacency   = NULL;
  104.     m_dwNumSegs       = 2;
  105.     m_bUseHWNPatches  = FALSE;
  106.     
  107.     m_pFont           = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
  108.  
  109.     _tcscpy( m_strInitialDir, DXUtil_GetDXSDKMediaPath() );
  110.     _tcscpy( m_strMeshFilename, _T("tiger.x") );
  111. }
  112.  
  113.  
  114.  
  115.  
  116. //-----------------------------------------------------------------------------
  117. // Name: OneTimeSceneInit()
  118. // Desc: Called during initial app startup, this function performs all the
  119. //       permanent initialization.
  120. //-----------------------------------------------------------------------------
  121. HRESULT CMyD3DApplication::OneTimeSceneInit()
  122. {
  123.     // Set cursor to indicate that user can move the object with the mouse
  124. #ifdef _WIN64
  125.     SetClassLongPtr( m_hWnd, GCLP_HCURSOR, (LONG_PTR)LoadCursor( NULL, IDC_SIZEALL ) );
  126. #else
  127.     SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)LoadCursor( NULL, IDC_SIZEALL ) );
  128. #endif
  129.     return S_OK;
  130. }
  131.  
  132.  
  133.  
  134.  
  135. //-----------------------------------------------------------------------------
  136. // Name: FrameMove()
  137. // Desc: Called once per frame, the call is the entry point for animating
  138. //       the scene.
  139. //-----------------------------------------------------------------------------
  140. HRESULT CMyD3DApplication::FrameMove()
  141. {
  142.      // Setup world matrix
  143.     D3DXMATRIX matWorld;
  144.     D3DXMATRIX matRotationInverse;
  145.     D3DXMatrixTranslation( &matWorld, -m_vObjectCenter.x,
  146.                                       -m_vObjectCenter.y,
  147.                                       -m_vObjectCenter.z );
  148.     D3DXMatrixInverse( &matRotationInverse, NULL, m_ArcBall.GetRotationMatrix() );
  149.     D3DXMatrixMultiply( &matWorld, &matWorld, &matRotationInverse );
  150.     D3DXMatrixMultiply( &matWorld, &matWorld, m_ArcBall.GetTranslationMatrix() );
  151.     m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
  152.  
  153.     D3DXMATRIX matView;
  154.     D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0, 0, -2*m_fObjectRadius ),
  155.                                   &D3DXVECTOR3( 0, 0, 0 ),
  156.                                   &D3DXVECTOR3( 0, 1, 0 ) );
  157.     m_pd3dDevice->SetTransform( D3DTS_VIEW,  &matView );
  158.  
  159.     return S_OK;
  160. }
  161.  
  162.  
  163.  
  164.  
  165. //-----------------------------------------------------------------------------
  166. // Name: Render()
  167. // Desc: Called once per frame, the call is the entry point for 3d
  168. //       rendering. This function sets up render states, clears the
  169. //       viewport, and renders the scene.
  170. //-----------------------------------------------------------------------------
  171. HRESULT CMyD3DApplication::Render()
  172. {
  173.     // Clear the backbuffer
  174.     m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 
  175.                          0x000000ff, 1.0f, 0L );
  176.  
  177.     // Begin the scene
  178.     if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
  179.     {
  180.         if (m_bUseHWNPatches)
  181.         {
  182.             float fNumSegs;
  183.  
  184.             fNumSegs = (float)m_dwNumSegs;
  185.             m_pd3dDevice->SetRenderState(D3DRS_PATCHSEGMENTS, *((DWORD*)&fNumSegs));
  186.         }
  187.  
  188.         // set and draw each of the materials in the mesh
  189.         for( UINT i = 0; i < m_dwNumMaterials; i++ )
  190.         {
  191.             m_pd3dDevice->SetMaterial( &m_pMaterials[i].MatD3D );
  192.             m_pd3dDevice->SetTexture( 0, m_ppTextures[i] );
  193.  
  194.             m_pMeshEnhanced->DrawSubset( i );
  195.         }
  196.  
  197.         if (m_bUseHWNPatches)
  198.         {
  199.             m_pd3dDevice->SetRenderState(D3DRS_PATCHSEGMENTS, 0);
  200.         }
  201.  
  202.         // Output stats
  203.         {
  204.             // Output statistics
  205.             m_pFont->DrawText(   2,  0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
  206.             m_pFont->DrawText(   2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
  207.  
  208.             TCHAR buffer1[80], buffer2[80];
  209.             _stprintf( buffer1, "NumSegs:" ); 
  210.             _stprintf( buffer2, "%d ", m_dwNumSegs );
  211.             m_pFont->DrawText(   2, 40, 0xffffff00, buffer1 );
  212.             m_pFont->DrawText( 150, 40, 0xffffffff, buffer2 );
  213.             _stprintf( buffer1, "NumFaces:" );
  214.             _stprintf( buffer2, "%d ", m_pMeshEnhanced->GetNumFaces() );
  215.             m_pFont->DrawText(   2, 60, 0xffffff00, buffer1 );
  216.             m_pFont->DrawText( 150, 60, 0xffffffff, buffer2 );
  217.             _stprintf( buffer1, "NumVertices:" );
  218.             _stprintf( buffer2, "%d ", m_pMeshEnhanced->GetNumVertices() );
  219.             m_pFont->DrawText(   2, 80, 0xffffff00, buffer1 );
  220.             m_pFont->DrawText( 150, 80, 0xffffffff, buffer2 );
  221.         }
  222.  
  223.         // End the scene.
  224.         m_pd3dDevice->EndScene();
  225.     }
  226.  
  227.     return S_OK;
  228. }
  229.  
  230.  
  231.  
  232.  
  233. //-----------------------------------------------------------------------------
  234. // Name: InitDeviceObjects()
  235. // Desc: This creates all device-dependent managed objects, such as managed
  236. //       textures and managed vertex buffers.
  237. //-----------------------------------------------------------------------------
  238. HRESULT CMyD3DApplication::InitDeviceObjects()
  239. {
  240.     LPDIRECT3DVERTEXBUFFER8 pVB = NULL;
  241.     BYTE*      pVertices = NULL;
  242.     LPD3DXMESH pTempMesh;
  243.     TCHAR      strMeshPath[512];
  244.     HRESULT    hr;
  245.  
  246.     // Initialize the font's internal textures
  247.     m_pFont->InitDeviceObjects( m_pd3dDevice );
  248.  
  249.     // Load the mesh from the specified file
  250.     DXUtil_FindMediaFile( strMeshPath, m_strMeshFilename );
  251.  
  252.     hr = D3DXLoadMeshFromX( strMeshPath, D3DXMESH_SYSTEMMEM, m_pd3dDevice, 
  253.                             &m_pbufAdjacency, &m_pbufMaterials, &m_dwNumMaterials, 
  254.                             &m_pMeshSysMem );
  255.     if( FAILED(hr) )
  256.         return D3DAPPERR_MEDIANOTFOUND;
  257.  
  258.     // Lock the vertex buffer, to generate a simple bounding sphere
  259.     hr = m_pMeshSysMem->GetVertexBuffer( &pVB );
  260.     if( FAILED(hr) )
  261.         return hr;
  262.  
  263.     hr = pVB->Lock( 0, 0, &pVertices, 0 );
  264.     if( FAILED(hr) )
  265.     {
  266.         SAFE_RELEASE( pVB );
  267.         return hr;
  268.     }
  269.  
  270.     hr = D3DXComputeBoundingSphere( pVertices, m_pMeshSysMem->GetNumVertices(), 
  271.                                     m_pMeshSysMem->GetFVF(), &m_vObjectCenter, 
  272.                                     &m_fObjectRadius );
  273.     if( FAILED(hr) )
  274.     {
  275.         pVB->Unlock();
  276.         SAFE_RELEASE( pVB );
  277.         return hr;
  278.     }
  279.  
  280.     if( 0 == m_dwNumMaterials )
  281.     {
  282.         pVB->Unlock();
  283.         SAFE_RELEASE( pVB );
  284.         return E_INVALIDARG;
  285.     }
  286.  
  287.     // Get the array of materials out of the returned buffer, allocate a
  288.     // texture array, and load the textures
  289.     m_pMaterials = (D3DXMATERIAL*)m_pbufMaterials->GetBufferPointer();
  290.     m_ppTextures = new LPDIRECT3DTEXTURE8[m_dwNumMaterials];
  291.  
  292.     for( UINT i=0; i<m_dwNumMaterials; i++ )
  293.     {
  294.         TCHAR strTexturePath[512] = _T("");
  295.         DXUtil_FindMediaFile( strTexturePath, m_pMaterials[i].pTextureFilename );
  296.         if( FAILED( D3DXCreateTextureFromFile( m_pd3dDevice, strTexturePath, 
  297.                                                &m_ppTextures[i] ) ) )
  298.             m_ppTextures[i] = NULL;
  299.     }
  300.  
  301.     pVB->Unlock();
  302.     SAFE_RELEASE( pVB );
  303.  
  304.     // Make sure there are normals, which are required for the tesselation
  305.     // enhancement
  306.     if( !(m_pMeshSysMem->GetFVF() & D3DFVF_NORMAL) )
  307.     {
  308.         hr = m_pMeshSysMem->CloneMeshFVF( m_pMeshSysMem->GetOptions(), 
  309.                                           m_pMeshSysMem->GetFVF() | D3DFVF_NORMAL, 
  310.                                           m_pd3dDevice, &pTempMesh );
  311.         if( FAILED(hr) )
  312.             return hr;
  313.  
  314.         D3DXComputeNormals( pTempMesh );
  315.  
  316.         SAFE_RELEASE( m_pMeshSysMem );
  317.         m_pMeshSysMem = pTempMesh;
  318.     }
  319.  
  320.     return S_OK;
  321. }
  322.  
  323.  
  324.  
  325.  
  326. //-----------------------------------------------------------------------------
  327. // Name: GenerateEnhancedMesh()
  328. // Desc: 
  329. //-----------------------------------------------------------------------------
  330. HRESULT CMyD3DApplication::GenerateEnhancedMesh( UINT dwNewNumSegs )
  331. {
  332.     LPD3DXMESH pMeshEnhancedSysMem = NULL;
  333.     LPD3DXMESH pMeshTemp;
  334.     HRESULT    hr;
  335.  
  336.     // if using hw, just copy the mesh
  337.     if (m_bUseHWNPatches)
  338.     {
  339.         hr = m_pMeshSysMem->CloneMeshFVF( D3DXMESH_WRITEONLY | D3DXMESH_NPATCHES, 
  340.                                 m_pMeshSysMem->GetFVF(), m_pd3dDevice, &pMeshTemp );
  341.         if( FAILED(hr) )
  342.             return hr;
  343.     }
  344.     else  // tesselate the mesh in sw
  345.     {
  346.  
  347.         // Create an enhanced version of the mesh, will be in sysmem since source is
  348.         hr = D3DXTesselateMesh( m_pMeshSysMem, (DWORD*)m_pbufAdjacency->GetBufferPointer(), 
  349.                                 (float)dwNewNumSegs, FALSE, &pMeshEnhancedSysMem );
  350.         if( FAILED(hr) )
  351.             return hr;
  352.  
  353.         // Make a vid mem version of the mesh
  354.         hr = pMeshEnhancedSysMem->CloneMeshFVF( D3DXMESH_WRITEONLY, m_pMeshSysMem->GetFVF(),
  355.                                                 m_pd3dDevice, &pMeshTemp );
  356.         if( FAILED(hr) )
  357.         {
  358.             SAFE_RELEASE( pMeshEnhancedSysMem );
  359.             return hr;
  360.         }
  361.  
  362.         // Latch in the enhanced mesh
  363.         SAFE_RELEASE( pMeshEnhancedSysMem );
  364.     }
  365.  
  366.     SAFE_RELEASE( m_pMeshEnhanced );
  367.     m_pMeshEnhanced = pMeshTemp;
  368.     m_dwNumSegs     = dwNewNumSegs;
  369.  
  370.     return S_OK;
  371. }
  372.  
  373.  
  374.  
  375.  
  376. //-----------------------------------------------------------------------------
  377. // Name: RestoreDeviceObjects()
  378. // Desc: Restore device-memory objects and state after a device is created or
  379. //       resized.
  380. //-----------------------------------------------------------------------------
  381. HRESULT CMyD3DApplication::RestoreDeviceObjects()
  382. {
  383.     HRESULT hr;
  384.  
  385.     m_bUseHWNPatches = (m_d3dCaps.DevCaps & D3DDEVCAPS_NPATCHES);
  386.  
  387.     hr = GenerateEnhancedMesh( m_dwNumSegs );
  388.     if( FAILED(hr) )
  389.         return hr;
  390.  
  391.     // Setup render state
  392.     m_pd3dDevice->SetRenderState( D3DRS_LIGHTING,     TRUE );
  393.     m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
  394.     m_pd3dDevice->SetRenderState( D3DRS_ZENABLE,      TRUE );
  395.     m_pd3dDevice->SetRenderState( D3DRS_AMBIENT,      0x33333333 );
  396.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
  397.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
  398.  
  399.     // Setup the light
  400.     D3DLIGHT8 light;
  401.     D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.0f,-1.0f, 1.0f );
  402.     m_pd3dDevice->SetLight(0, &light );
  403.     m_pd3dDevice->LightEnable(0, TRUE );
  404.  
  405.     // Setup the arcball parameters
  406.     m_ArcBall.SetWindow( m_d3dsdBackBuffer.Width, m_d3dsdBackBuffer.Height, 0.85f );
  407.  
  408.     // Setup the projection matrix
  409.     D3DXMATRIX matProj;
  410.     FLOAT      fAspect = (FLOAT)m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
  411.     D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 
  412.                                 m_fObjectRadius/64.0f, m_fObjectRadius*200.0f );
  413.     m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
  414.  
  415.     // Restore the font
  416.     m_pFont->RestoreDeviceObjects();
  417.  
  418.     return S_OK;
  419. }
  420.  
  421.  
  422.  
  423.  
  424. //-----------------------------------------------------------------------------
  425. // Name: InvalidateDeviceObjects()
  426. // Desc: Called when the device-dependent objects are about to be lost.
  427. //-----------------------------------------------------------------------------
  428. HRESULT CMyD3DApplication::InvalidateDeviceObjects()
  429. {
  430.     m_pFont->InvalidateDeviceObjects();
  431.  
  432.     SAFE_RELEASE( m_pMeshEnhanced );
  433.  
  434.     return S_OK;
  435. }
  436.  
  437.  
  438.  
  439.  
  440. //-----------------------------------------------------------------------------
  441. // Name: DeleteDeviceObjects()
  442. // Desc: Called when the app is exiting, or the device is being changed,
  443. //       this function deletes any device dependent objects.
  444. //-----------------------------------------------------------------------------
  445. HRESULT CMyD3DApplication::DeleteDeviceObjects()
  446. {
  447.     m_pFont->DeleteDeviceObjects();
  448.  
  449.     for( UINT i = 0; i < m_dwNumMaterials; i++ )
  450.         SAFE_RELEASE( m_ppTextures[i] );
  451.     SAFE_DELETE_ARRAY( m_ppTextures );
  452.     SAFE_RELEASE( m_pMeshSysMem );
  453.     SAFE_RELEASE( m_pbufMaterials );
  454.     m_dwNumMaterials = 0L;
  455.  
  456.     return S_OK;
  457. }
  458.  
  459.  
  460.  
  461.  
  462.  
  463. //-----------------------------------------------------------------------------
  464. // Name: FinalCleanup()
  465. // Desc: Called during initial app startup, this function performs all the
  466. //       permanent initialization.
  467. //-----------------------------------------------------------------------------
  468. HRESULT CMyD3DApplication::FinalCleanup()
  469. {
  470.     SAFE_DELETE( m_pFont );
  471.  
  472.     return S_OK;
  473. }
  474.  
  475.  
  476.  
  477.  
  478. //-----------------------------------------------------------------------------
  479. // Name: MsgProc()
  480. // Desc: Message proc function to handle key and menu input
  481. //-----------------------------------------------------------------------------
  482. LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
  483.                                     LPARAM lParam )
  484. {
  485.     // Pass mouse messages to the ArcBall so it can build internal matrices
  486.     m_ArcBall.HandleMouseMessages( hWnd, uMsg, wParam, lParam );
  487.  
  488.     // Trap context menu
  489.     if( WM_CONTEXTMENU == uMsg )
  490.         return 0;
  491.  
  492.     // Handle key presses
  493.     if( WM_KEYDOWN == uMsg )
  494.     {
  495.         if( VK_UP == (int)wParam )
  496.             GenerateEnhancedMesh( m_dwNumSegs + 1 );
  497.         
  498.         if( VK_DOWN == (int)wParam )
  499.             GenerateEnhancedMesh( max( 1, m_dwNumSegs - 1 ) );
  500.  
  501.         if( 'W' == (int)wParam )
  502.             m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
  503.  
  504.         if( 'S' == (int)wParam )
  505.             m_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
  506.     }
  507.     else if( uMsg == WM_COMMAND )
  508.     {
  509.             // Handle the open file command
  510.         if( LOWORD(wParam) == IDM_OPENFILE )
  511.         {
  512.             TCHAR g_strFilename[512]   = _T("");
  513.  
  514.             // Display the OpenFileName dialog. Then, try to load the specified file
  515.             OPENFILENAME ofn = { sizeof(OPENFILENAME), NULL, NULL,
  516.                                 _T(".X Files (.x)\0*.x\0\0"), 
  517.                                 NULL, 0, 1, m_strMeshFilename, 512, g_strFilename, 512, 
  518.                                 m_strInitialDir, _T("Open Mesh File"), 
  519.                                 OFN_FILEMUSTEXIST, 0, 1, NULL, 0, NULL, NULL };
  520.  
  521.             if( TRUE == GetOpenFileName( &ofn ) )
  522.             {
  523.                 _tcscpy( m_strInitialDir, m_strMeshFilename );
  524.                 TCHAR* pLastSlash =  _tcsrchr( m_strInitialDir, _T('\\') );
  525.                 if( pLastSlash )
  526.                     *pLastSlash = 0;
  527.                 SetCurrentDirectory( m_strInitialDir );
  528.  
  529.                 // Destroy and recreate everything
  530.                 InvalidateDeviceObjects();
  531.                 DeleteDeviceObjects();
  532.                 InitDeviceObjects();
  533.                 RestoreDeviceObjects();
  534.             }
  535.         }
  536.     }
  537.  
  538.  
  539.     // Pass remaining messages to default handler
  540.     return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
  541. }
  542.  
  543.  
  544.  
  545.